package com.rightsidetech.http.controller.agentApp.news;

import com.github.pagehelper.PageInfo;
import com.rightsidetech.commom.base.ResponseData;
import com.rightsidetech.http.aspect.Log;
import com.rightsidetech.system.dtos.request.news.AgentAppPageReq;
import com.rightsidetech.system.dtos.request.news.NewsTypeReq;
import com.rightsidetech.system.dtos.response.news.AgentAppPageResp;
import com.rightsidetech.system.dtos.response.news.NewsTypePageResp;
import com.rightsidetech.system.service.SysNewsService;
import com.rightsidetech.system.service.SysNewsTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/agentApp/news")
@ShenyuSpringMvcClient(path = "/agentApp/news/**")
@Api(tags = "代理商新闻社区相关")
public class AgentAppNewsController {

    @Resource
    private SysNewsService sysNewsService;
    @Resource
    private SysNewsTypeService sysNewsTypeService;

    @Log
    @GetMapping("/page")
    @ApiOperation("代理商电池社区分页")
    public ResponseData<PageInfo<AgentAppPageResp>> page(AgentAppPageReq req) {
        return sysNewsService.appPage(req, (byte) 1);
    }

    @Log
    @GetMapping("/type")
    @ApiOperation("社区分类")
    public ResponseData<List<NewsTypePageResp>> typeSearch() {
        NewsTypeReq newsTypeReq = new NewsTypeReq();
        newsTypeReq.setPlatform((byte)1);
        return sysNewsTypeService.selectAppList(newsTypeReq);
    }
}
